package com.ledijiaoyu.autogate.ui;

import java.lang.ref.WeakReference;

/**
 * Create with Android Studio
 * Author: chengpengfei
 * Date: 2018/5/22
 * Time: 1:48 PM
 * Description: Presenter 基类实现类
 */
public class BasePresenter<V>  implements IPresenter{


    protected WeakReference<V> mView;


    /**
     * 构造器
     * @param mView
     */
    public BasePresenter(V mView) {
        this.mView = new WeakReference<>(mView);
    }


    /**
     * 获取绑定的视图
     * @return
     */
    protected V getView(){
        return mView.get();
    }


    @Override
    public boolean isViewActive() {
        return null != mView && null != mView.get();
    }


    @Override
    public void detachView() {
        mView.clear();
        mView = null;
    }
}
